<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"
>


<!-- 导入公有的header -->
<head th:include="common/head::header"/>


<body class="hold-transition skin-blue sidebar-mini">

    <!-- DataTables -->
    <script th:src="@{/plug-in/adminLTE/plugins/datatables/jquery.dataTables.min.js}"></script>
    <script th:src="@{/plug-in/adminLTE/plugins/datatables/dataTables.bootstrap.min.js}"></script>


    <!-- =============================================== -->
    <!-- Main content -->
    <section class="content">

        <!-- PRODUCT LIST -->

            <div class="box-header with-border">
                <h3 class="box-title">系统进程列表</h3>
            </div>
            <!-- /.box-header -->

                <ul class="products-list product-list-in-box">
                    <li class="item" th:each="p,rowIndex: ${processList}">
                        <div class="product-img">
                            <img th:src="@{/plug-in/adminLTE/dist/img/exe.png }" alt="文件类型图片">
                        </div>
                        <div class="product-info">
                            <!-- 编号 -->
                            <span ><small class="badge bg-green" th:text="${rowIndex.index}"></small></span>
                            <a href="javascript:void(0)" class="product-title"><span th:text="${p.name}"></span>
                                <span class="label label-info pull-right" th:text="${p.pid}"></span>
                            </a>
                            <span class="product-description" th:text="${p.path}"></span>
                            <span class="product-description" style="font-style: italic" th:text="${p.user}"></span>
                        </div>
                        <!-- 如果是文件操作工具条 -->
                        <div class="product-info" >
                            <table width="100%">
                                <tr>
                                    <td class="has-warning" style="vertical-align: bottom">
                                        <label  class="control-label" ><i class="fa fa-clock-o"></i> <span th:text="${p.start}"></span></label>
                                    </td>
                                    <td align="right" width="110">
                                        <button type="button"  class="btn btn-danger btn-xs" th:onclick="submitExecKillByPid([[${p.pid}]]);"><i class="fa fa-remove" ></i>Kill</button>
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </li>
                    <!-- /.item -->
                </ul>
            <!-- /.box-footer -->

    </section>
    <!-- /.content -->
    <script type="application/javascript">
        function submitExecKillByPid(pid){
            window.parent.$.dialog.confirm('你确定要执行[杀掉进程]吗？', function(){
                execKillByPid(pid);
            }, function(){
                window.parent.$.dialog.tips('执行取消操作');
            });
        }
        function execKillByPid(processPid){
            var urlStr = ctxPath + '/jm/manager/process/killByPid';
            jQuery.ajax({
                url: urlStr,
                type: "POST",
                dataType: 'json',//接受数据格式
                data: {pid:processPid},   //要传递的数据
                async: false,
                success: function (data) {
                    if(data.data){
                        window.parent.alertSuccess('kill 进程成功！');
                    }else{
                        window.parent.alertError('kill 进程失败！');
                    }
                },
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                    window.parent.alertError('kill 进程异常！');
                }
            });
        }
    </script>
</body>
</html>
